package com.xiyue.leaspring.action;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller//定义控制器
@RequestMapping("/pages/message")//定义访问父路径，与方法中的路径组合为完整的路径
public class EchoAction {//自定义Action程序

    @PreAuthorize("hasRole('ADMIN')")
    @RequestMapping("/show")//访问的路径为url
    public ModelAndView echo(String msg){
        return new ModelAndView("/message/message_show").addObject("echoMessage","[ECHO]msg="+msg);
    }

    @PreAuthorize("hasRole('ADMIN')")
    @GetMapping("/input")//访问的路径
    public String input(){
        return "/message/message_input";//jump route
    }
}